package com.aimee.mvp.presenter;

import com.aimee.mvp.bean.Account;
import com.aimee.mvp.callback.ResultCallBack;
import com.aimee.mvp.model.MVPModel;
import com.aimee.mvp.view.IMVPView;

/**
 * 需要持有View与model层的引用
 */
public class MVPPresenter {
    private IMVPView mIMVPView;
    private MVPModel mMVPModel;

    public MVPPresenter(IMVPView mIMVPView) {
        this.mIMVPView = mIMVPView;
        mMVPModel = new MVPModel();
    }

    public void getData(String accountName) {
        mMVPModel.getAccountData(accountName, new ResultCallBack() {
            @Override
            public void onSuccess(Account account) {
                mIMVPView.showSuccessPage(account);
            }

            @Override
            public void onFail() {
                mIMVPView.showFailPage();
            }
        });
    }
}
